package com.samuel.igoodman.web.system;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import com.samuel.igoodman.dao.article.ArticleDao;
import com.samuel.igoodman.entity.Page;
import com.samuel.igoodman.entity.article.Article;
import com.samuel.igoodman.entity.book.BookContent;
import com.samuel.igoodman.web.base.BaseAction;

/**
 * 系统首页
 * @author samuel
 */
@SuppressWarnings("serial")
public class HomeAction extends BaseAction {

	/*【系统首页】*/
	@SuppressWarnings("unchecked")
	public String home(){
		/**
		 * 系统今天阅读内容
		 */
		String today =  new SimpleDateFormat("yyyy-MM-dd").format(new Date());
		BookContent bookContent = new BookContent();
		bookContent.setDate(today);
		List<BookContent> bookContentList =  (List<BookContent>) bookContent.Filter(bookContent.where(), 1, 1);
		if(null!=bookContentList&&bookContentList.size()>0){
			setRequestAtt("bookContent", bookContentList.get(0));
		}
		
		/**
		 * 网友的分享
		 */
		List<Article> articleList =  ArticleDao.getArticleByDate(today, 1, Page.PAGE_SIZE);
		setRequestAtt("articleList", articleList);
		
		return SUCCESS;
	}
	
}
